// import { initData } from '../utils';
// import axios, { AxiosResponse } from 'axios';
// import {FaucetInterface, ReportInterface} from '../model'
// import {DailyReportInterface} from '../model'
// import {HourlyReportInterface} from '../model'
// import { FiveMinitesReportInterface } from "../model";
// import { Collection } from 'mongodb';
// // import { createFaucetClient, FaucetClient } from './faucet';
// const  faucetArr = new Array<FaucetInterface>();
// const  dailyArr = new Array<DailyReportInterface>();
// const  hourArr = new Array<HourlyReportInterface>();
// const  fiveArr = new Array<FiveMinitesReportInterface>();

// let FaucetCfg = {
//     uri:"mongodb://172.16.0.104",
//     db:"fauce"
// }
// // let faucetClient = createFaucetClient(FaucetCfg);
// // FaucetCfg.db='daily'
// // let dailyClient = createFaucetClient(FaucetCfg);
// // FaucetCfg.db='hour'
// // let hourClient = createFaucetClient(FaucetCfg);
// // FaucetCfg.db='fiveMins'
// // let fiveClient = createFaucetClient(FaucetCfg);


// export interface faucetData{
//     _id:string
//     name:string
//     url:string
//     currency:string
//     lastPayment:number
//     balance:number
//     paid_hour:number
//     paid_day: number
//     createTime:string
// }

// let faucetDatas = new Array<faucetData>();
// initFaucetData();
// // initTimeData();
// // findFaucet();
// // updateFaucet()
// export async function initFaucetData() {
//     axios.get('https://faucetpay.io/api/listv1/faucetlist').then(async(res:any)=>{
//         let data = res.data.list_data.normal;
//         initData(data.BCH,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.BNB,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.BTC,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.DASH,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.DGB,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.DOGE,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.ETH,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.FEY,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.LTC,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.TRX,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.USDT,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.ZEC,faucetArr,dailyArr,hourArr,fiveArr)
//         let fId = (await faucetClient).insertMany(faucetArr)
//         let dId = (await dailyClient).insertMany(dailyArr)
//         let hId = (await hourClient).insertMany(hourArr)
//         let vId = (await fiveClient).insertMany(fiveArr)   
//         console.log("数据表添加完成")
//     })
   
// }

// // export let faucerData:Promise<(FaucetInterface | ReportInterface)[]>;
// export async function findFaucet(req?:any) {
//     let condotion:string[] = [];
//     let fArr:FaucetInterface[];
//     let dArr:(FaucetInterface | ReportInterface)[];
//     let hArr:(FaucetInterface | ReportInterface)[];
//     let index:number;
//     if(req!=null){
//          condotion= req.split("=",2)


//         if('latest_payment_time'===condotion[1]){
//             console.log("执行时间排序")
//              fArr = (await (await faucetClient).getManyPlusFaucet("latest_payment_time"));
//              dArr = (await (await dailyClient).getManyPlus());
//              hArr = (await (await hourClient).getManyPlus());
//              console.log(dArr[38])
//              console.log(hArr[38])
             
//         }else if('paid_hour'===condotion[1]||'paid_day'===condotion[1]){
//             console.log('金额排序')
//             fArr = (await (await faucetClient).getManyPlusFaucet());
//             dArr = (await (await dailyClient).getManyPlus("paid_sort"));
//             hArr = (await (await hourClient).getManyPlus());
//         }else{
//             console.log("执行条件查询")
//             fArr = (await (await faucetClient).getManyPlusFaucet("ZEC"));
//             dArr = (await (await dailyClient).getManyPlus());
//             hArr = (await (await hourClient).getManyPlus());
//         }
        
//     }else{
//         console.log("执行查询")
//          fArr = (await (await faucetClient).getManyPlusFaucet());
//          dArr = (await (await dailyClient).getManyPlus());
//          hArr = (await (await hourClient).getManyPlus());
    
//     }

    
   
    

//     if(condotion[0]==='currency'||condotion[1]==='latest_payment_time'){
//         console.log("gogogoggogo")
//         console.log(fArr.length)
//         fArr.forEach((element,index) => {
//             console.log(Number(element._id))
//             let i = Number(element._id)-1;
//                 faucetDatas[index]={
//                     _id:element._id,
//                     name:element.name,
//                     url:element.url,
//                     currency:element.currency,
//                     lastPayment:element.latest_payment_time,
//                     balance:element.balance,
//                     createTime:element.createTime,
//                     paid_day: dArr[i].balance*100,
//                     paid_hour: hArr[i].balance*10,
            
//                 }
//                 // console.log(index)
//         });
//     }else{
//         dArr.forEach((element,index) => {
//             let i = Number(element._id)-1;
//                 faucetDatas[index]={
//                     _id:fArr[i]._id,
//                     name:fArr[i].name,
//                     url:fArr[i].url,
//                     currency:fArr[i].currency,
//                     lastPayment:fArr[i].latest_payment_time,
//                     balance:fArr[i].balance,
//                     createTime:fArr[i].createTime,
//                     paid_day: element.balance,
//                     paid_hour: hArr[i].balance/100,
            
//             }
//         });
//     }
    


    
//     return faucetDatas;
// }


// export async function updateFaucet() {
//     axios.get('https://faucetpay.io/api/listv1/faucetlist').then(async(res:any)=>{
//         let data = res.data.list_data.normal;
//         initData(data.BCH,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.BNB,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.BTC,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.DASH,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.DGB,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.DOGE,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.ETH,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.FEY,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.LTC,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.TRX,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.USDT,faucetArr,dailyArr,hourArr,fiveArr)
//         initData(data.ZEC,faucetArr,dailyArr,hourArr,fiveArr);


//         (await faucetClient).updateFaucet(faucetArr);
//         (await dailyClient).updateReport(dailyArr);
//         (await hourClient).updateReport(hourArr);
//         (await fiveClient).updateReport(fiveArr);

//         console.log("数据表更新完成")
//     })
// }

// // }